from typing import List, Dict, Tuple


class Database:
    def __init__(self):
        self.tables: Dict[int, Tuple[int, int, List[int], List[List[int]]]] = {}

    def create(self, table_id: int, col_num: int, keys: str):
        if table_id in self.tables:
            return

        sort_cols = [ord(c) - ord('a') for c in keys]
        if any(col >= col_num for col in sort_cols):
            return

        for i in range(col_num):
            if i not in sort_cols:
                sort_cols.append(i)

        self.tables[table_id] = (table_id, col_num, sort_cols, [])

    def insert(self, table_id: int, values: List[int]):
        if table_id not in self.tables:
            return

        _, col_num, sort_cols, entries = self.tables[table_id]
        if len(values) != col_num:
            return

        entries.append(values)

    def select(self, table_id: int, conditions: List[str]):
        def match(values, conditions):
            for condition in conditions:
                key, value = condition.split('=')
                key = ord(key) - ord('a')
                if key >= len(values) or values[key] != value:
                    return False
            return True

        _, col_num, sort_cols, entries = self.tables[table_id]
        selected = [values for values in entries if match(values, conditions)]
        selected.sort(key=lambda entry: [entry[col] for col in sort_cols])
        return selected
